package com.chidopi.market.aa.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.chidopi.cdf.struts1actions.CdfDispatchAction;
import com.chidopi.market.aa.forms.LoginForm;


public class LoginAction extends CdfDispatchAction {
	private static Logger logger = LoggerFactory.getLogger(LoginAction.class);

	public ActionForward login(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		LoginForm loginForm = (LoginForm) form;
		logger.info("UserID=" + loginForm.getUserid());
		logger.info("Password=" + loginForm.getPassword());
//		try {
//			IBar bar = (IBar) ModelContextFactory.get(IBar.class);
//			logger.info("name_tw=" + bar.queryUsernameById(loginForm.getUserid()));
//		} catch (Exception e) {
//			logger.warn("get", e);
//		}
		return mapping.findForward("success");
	}

	public ActionForward echo(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		logger.info("echo here!!");
		return mapping.findForward("success");
	}
}
